package com.movieknight;

import android.app.TabActivity;
import android.os.Bundle;
import android.widget.TabHost;
import android.content.Intent;
import android.content.res.Resources;

// Main activity called when the application is launched. Contains tab definitions.

public class TheTabActivity extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tab);

        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, HomeActivity.class);
        spec = tabHost.newTabSpec("home").setIndicator("Home", res.getDrawable(R.drawable.ic_tab_home)).setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, MoviesActivity.class);
        spec = tabHost.newTabSpec("movies").setIndicator("Movies",res.getDrawable(R.drawable.ic_tab_movie)).setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, FriendsActivity.class);
        spec = tabHost.newTabSpec("friends").setIndicator("Friends",res.getDrawable(R.drawable.ic_tab_user)).setContent(intent);
        tabHost.addTab(spec);

        tabHost.setCurrentTab(0);
    }
    
    public void onDestroy()
    {
    	super.onDestroy();
    	((MovieKnightApp) this.getApplication()).setSessionID("");    	
    	((MovieKnightApp) this.getApplication()).setTabsLaunched(false);
    }
    
}